package com.zhangyu.shadow.repair.delegate.search;

import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

import com.zhangyu.shadow.repair.delegate.bean.BusTypeBean;

import java.util.List;

/**
 * Created by 张宇 on 2017/3/14.
 */

public class SearchPagerAdapter extends FragmentStatePagerAdapter {
    private List<TabFragment> mDelegates;
    private List<BusTypeBean> mTitles;

    public SearchPagerAdapter(FragmentManager fm,
                              List<TabFragment> fragments,
                              List<BusTypeBean> titles) {
        super(fm);
        this.mDelegates = fragments;
        mTitles = titles;
    }

    @Override
    public Fragment getItem(int position) {
        return mDelegates.get(position);
    }

    @Override
    public int getCount() {
        return mDelegates.size();
    }

    @Nullable
    @Override
    public CharSequence getPageTitle(int position) {
        BusTypeBean bean = mTitles.get(position);
        return bean.getName() + "(" + bean.getCount() + ")";
    }


}
